package com.example.mobile2021606127cxz0420;

import android.os.Bundle;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

public class MainActivity extends AppCompatActivity {

    private TextView tvMainTitle;
    private RecyclerView rv;
    private int[] photo = {R.drawable.ui_body01, R.drawable.ui_dipan01, R.drawable.ui_door01, R.drawable.ui_fadongji01, R.drawable.ui_fangxiangpan01, R.drawable.ui_houboli01, R.drawable.ui_luntai01, R.drawable.ui_qianboli01, R.drawable.ui_qiangai01, R.drawable.ui_xuangua01, R.drawable.ui_zhuoyi01};
    private String[] text = {"车身", "底盘", "车门", "发动机", "方向盘", "后玻璃", "轮胎", "前玻璃", "前盖", "悬挂", "座椅"};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();

        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        rv.setLayoutManager(linearLayoutManager);

//        GridLayoutManager gridLayoutManager=new GridLayoutManager(this,2);
//        rv.setLayoutManager(gridLayoutManager);
        CarAdapter adapter = new CarAdapter(photo, text);
        rv.setAdapter(adapter);
    }

    private void initView() {
        tvMainTitle = (TextView) findViewById(R.id.tv_main_title);
        rv = (RecyclerView) findViewById(R.id.rv);
    }
}